import request from '@/utils/request'

/**
  * 获取部门的员工列表
  * @param {object} params
  * @returns
  */
export const getEmployeeListAPI = (params) => {
  return request.get('/sys/user', { params })
}

// 导出excel
export const exportExcelAPI = () => {
  return request.get('/sys/user/export', {
    // 如果响应的数据是二进制格式的,需要指定responseType
    responseType: 'blob'
  })
}

// 下载导入excel
export const downloadExcelAPI = () => {
  return request.get('/sys/user/import/template', {
    // 如果响应的数据是二进制格式的,需要指定responseType
    responseType: 'blob'
  })
}

// 上传文件
export const handleUploadAPI = (data) => {
  return request.post('/sys/user/import', data)
}

// 删除员工
export const delEmployeeAPI = (id) => {
  return request.delete(`/sys/user/${id}`)
}

// 添加员工
export const addEmployeeAPI = (data) => {
  return request.post('/sys/user', data)
}
// 员工详情
export const getEmployeeDetailAPI = (id) => {
  return request.get(`/sys/user/${id}`)
}
// 修改员工
export const updateEmployeeAPI = (data) => {
  return request.put(`/sys/user/${data.id}`, data)
}
/**
 * 获取已启用的角色列表
 */
export const getEnableRolesAPI = () => {
  return request.get('/sys/role/list/enabled')
}

// 员工分配角色接口
export const assignRolesAPI = (data) => {
  return request.put('/sys/user/assignRoles', data)
}
